//
//  GlobalModel.swift
//  MiU
//
//  Created by linhan on 15/11/9.
//  Copyright © 2015年 MiU. All rights reserved.
//

import Foundation

/// Error domain of Kingfisher
public let MiuErrorDomain = "com.ms.error"

struct SWError
{
    static let domain = "com.ms.error"
    
    static let DefaultNetworkError = NSError(domain: MiuErrorDomain, code: 404, userInfo: [NSLocalizedDescriptionKey:"网络故障，请稍后重试"])
    
    
    static let DataError = NSError(domain: MiuErrorDomain, code: 401, userInfo: [NSLocalizedDescriptionKey:"数据异常"])
    static let LoginError = NSError(domain: MiuErrorDomain, code: 405, userInfo: [NSLocalizedDescriptionKey:"数据异常"])
    
    static let RequestKeyError = NSError(domain: MiuErrorDomain, code: 406, userInfo: [NSLocalizedDescriptionKey:"数据异常"])
    
    static let TokenInvalidError = NSError(domain: MiuErrorDomain, code: 407, userInfo: [NSLocalizedDescriptionKey:"Token无效异常"])
    
    static let FilterDefaultError = NSError(domain: MiuErrorDomain, code: 800, userInfo: [NSLocalizedDescriptionKey:"图片处理失败"])
}

extension NSError
{
    var message:String{
        return userInfo[NSLocalizedDescriptionKey] as? String ?? ""
    }
}

struct SWErrorCode {
    static let LOGIN_BUT_NO_EXIST:Int = 402
    static let LOGIN_BUT_PASSWORD_ERROR:Int = 401
    static let REGISTER_BUT_MOBILE_EXIST:Int = 3011
    static let PASSWORD_RESET_BUT_NOT_EXIST:Int = 3013
    static let PHONE_BINDING_BUT_BINDED:Int = 3016
    static let PHONE_BINDING_BUT_OCCUPY:Int = 3017
    //验证码错误
    static let VERIFY_CODE_ERROR:Int = 102
    //验证码失效(失效后需要启用获取按钮)
    static let VERIFY_CODE_Invalid:Int = 101
    
    //Token过期失效
    static let Token_EXPIRE:Int = 3021
}

//获取验证码的目的（注册、重置密码等）
enum GetVerifyPurpose:Int
{
    case Register
    case ResetPassword
}

//enum WeixinShareScene:Int
//{
//    case Session
//    case Space
//    
//    static func getSceneFormAction(action:SWShareAction) -> WeixinShareScene
//    {
//        if action == .WeixinSession
//        {
//            return .Session
//        }
//        return .Space
//    }
//}

//分享渠道
enum InviteChannel:String
{
    case None = "none"
    case Contact = "Contact"
    case Weixin = "Weixin"
    case WeixinSpace = "WeixinSpace"
    case Weibo = "Weibo"
    case Internal = "Internal"
}

struct CallbackAction
{
    static let ShowUserInfoSetting:String = "MenuAction_ShowUserInfoSetting"
    static let ShowGeneralSetting:String = "MenuAction_ShowGeneralSetting"
    static let ShowFriends:String = "MenuAction_ShowFriends"
    static let ShowFollowers:String = "MenuAction_ShowFollowers"
    static let AddFriends:String = "MenuAction_AddFriends"
    static let InviteFriends:String = "MenuAction_InviteFriends"
    static let Follow:String = "MenuAction_Follow"
    static let UnFollow:String = "MenuAction_UnFollow"
    static let Mark:String = "MenuAction_Mark"
    static let Unmark:String = "MenuAction_Unmark"
    static let JoinGroup:String = "MenuAction_JoinGroup"
    static let ShowFeedDetail:String = "MenuAction_ShowFeedDetail"
    static let ShowUserDetail:String = "MenuAction_ShowUserDetail"
    static let ShowTopicDetail:String = "MenuAction_ShowTopicDetail"
    static let ShowBrandDetail:String = "MenuAction_ShowBrandDetail"
    static let ShowGroupDetail:String = "MenuAction_ShowGroupDetail"
    static let ShowHistory:String = "MenuAction_ShowHistory"
    static let ShowComment:String = "MenuAction_ShowComment"
    static let PlazaCircleTap:String = "MenuAction_PlazaCircleTap"
    
    static let Agree:String = "MenuAction_Pop"
    static let Pay:String = "Pay"
    
    
    static let Detail:String = "MenuAction_Detail"
    static let Favorite:String = "MenuAction_Favorite"
    static let Expand:String = "MenuAction_Expand"
    static let Collapse:String = "MenuAction_Collapse"
    static let Tap:String = "MenuAction_Tap"
    static let LongPress:String = "MenuAction_LongPress"
    static let Delete:String = "MenuAction_Delete"
    static let Unlike:String = "MenuAction_Unlike"
    static let Like:String = "MenuAction_Like"
    static let Share:String = "MenuAction_Share"
    static let Prev:String = "MenuAction_Prev"
    static let Next:String = "MenuAction_Next"
    static let More:String = "MenuAction_More"
    static let Pop:String = "MenuAction_Pop"
    static let Add:String = "MenuAction_Add"
    static let Close:String = "MenuAction_Close"
    static let Select:String = "MenuAction_Select"
    static let Deselect:String = "MenuAction_Deselect"
    static let Upload:String = "Upload"
    static let Finish:String = "Finish"
    
    
    
}

extension NSNotification.Name {
    //static let aa = Self(rawValue:"aaa")
}

struct NotificationName {
    
    
    
    static let NeedLogin = NSNotification.Name(rawValue:"NotificationName_NeedLogin")
    static let LoginSuccess = NSNotification.Name(rawValue:"NotificationName_LoginSuccess")
    static let Logout = NSNotification.Name(rawValue:"NotificationName_Logout")
    static let TokenExpire = NSNotification.Name(rawValue:"NotificationName_TokenExpire")
    
    
    static let ChildInfoChanged = NSNotification.Name(rawValue:"NotificationName_ChildInfoChanged")
    static let StickerRemoved = NSNotification.Name(rawValue:"NotificationName_StickerRemoved")
    
    //收藏事件
    static let LikeKidEvent = NSNotification.Name(rawValue:"LikeKidEvent")
    static let DislikeKidEvent = NSNotification.Name(rawValue:"DislikeKidEvent")
    
    //从相册中删除图片
    static let DeleteAsset = NSNotification.Name(rawValue:"DeleteAsset")
    static let AssetChanged = NSNotification.Name(rawValue:"AssetChanged")
    //照片类别改变（新添加、已添加更改分类）
    static let AssetClassified = NSNotification.Name(rawValue:"AssetClassified")
    
    
    static let AccountInfoChanged = NSNotification.Name(rawValue:"NotificationName_AccountInfoChanged")
    static let ChildAccountInfoChanged = NSNotification.Name(rawValue:"ChildAccountInfoChanged")
    //用户发的内容数量发生变化时通知
    static let UCGCountChanged = NSNotification.Name(rawValue:"NotificationName_UCGCountChanged")
    
    //未读消息数量发生变化
    static let UnreadMessageCountChanged = NSNotification.Name(rawValue:"NotificationName_UnreadMessageCountChanged")
    
    //进入购物篮的页面数量变化
    static let PageProductCountChanged = NSNotification.Name(rawValue:"PageProductCountChanged")
    
    //书本页面变化(图片、文字变化)
    static let BookPageUpdated = NSNotification.Name(rawValue:"BookPageUpdated")
    //书本页面图片变化
    static let BookPagePhotoUpdated = NSNotification.Name(rawValue:"BookPagePhotoUpdated")
    //手动把页面填补完整
    static let PageCompletedManual = NSNotification.Name(rawValue:"PageCompletedManual")
    
    //付款成功
    static let PaySuccess = NSNotification.Name(rawValue:"PaySuccess")
    
    //单张图上传完成
    static let PageUploadComplete = NSNotification.Name(rawValue:"PageUploadComplete")
    //一个队列上传完成
    static let PageUploadQueueComplete = NSNotification.Name(rawValue:"PageUploadQueueComplete")
    //订单里的照片上传完成
    static let PageUploadAllComplete = NSNotification.Name(rawValue:"PageUploadAllComplete")
    //上传进度变化
    static let UploadProgressChanged = NSNotification.Name(rawValue:"UploadProgressChanged")
    //订单里的照片保存完成
    static let OrderPagesUpdateComplete = NSNotification.Name(rawValue:"OrderPagesUpdateComplete")
    
    static let RemoteMessageLoadedFinish = NSNotification.Name(rawValue:"NotificationName_RemoteMessageLoadedFinish")
    
    
    static let RemoteMessageLoadedFail = NSNotification.Name(rawValue:"NotificationName_RemoteMessageLoadedFail")
    
    static let DownloadTaskComplete = NSNotification.Name(rawValue:"NotificationName_DownloadTaskComplete")
    static let DownloadTaskFail = NSNotification.Name(rawValue:"NotificationName_DownloadTaskFail")
    
    static let GenerationTaskComplete = NSNotification.Name(rawValue:"GenerationTaskComplete")
    static let GenerationTaskAllComplete = NSNotification.Name(rawValue:"GenerationTaskAllComplete")
    
    static let UploadTaskComplete = NSNotification.Name(rawValue:"UploadTaskComplete")
    static let UploadTaskAllComplete = NSNotification.Name(rawValue:"UploadTaskAllComplete")
    static let UploadTaskFail = NSNotification.Name(rawValue:"UploadTaskFail")
    
    static let PhotoUpdated = NSNotification.Name(rawValue:"PhotoUpdated")
    
    static let Navigation = NSNotification.Name(rawValue:"Navigation")
    
}

struct SWKey
{
    static let localID:String = "localID"
    static let remoteURL:String = "remoteURL"
    static let index:String = "index"
    static let eventID:String = "eventID"
    static let pageID:String = "pageID"
    static let bookID:String = "bookID"
    static let newLocalID:String = "newLocalID"
    static let oldLocalID:String = "oldLocalID"
    static let orderID:String = "orderID"
    static let progress:String = "progress"
    static let imageID:String = "imageID"
    
    
    static let ViewController:String = "ViewController"
    
}

struct CookieKey
{
    //分享的图片上打水印
    static let autoUploadOnWifi:String = "autoUploadOnWifi"
    static let musicPlayableOnCellular:String = "musicPlayableOnCellular"
}

//广场首页下品牌、用户的圆形视图
struct PlazaCircleCellModel
{
    var name:String?
    var thumb:String?
}

